CSharpTest.Net
Merge(IComparer<T>,IEnumerable<T>,IEnumerable<T>) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > Merge Method : Merge(IComparer<T>,IEnumerable<T>,IEnumerable<T>) Method

comparer
x
y

Glossary Item Box

Merges two ordered enumerations based on the comparer provided.

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function Merge( _
   ByVal comparer As IComparer(Of T), _
   ByVal x As IEnumerable(Of T), _
   ByVal y As IEnumerable(Of T) _
) As IEnumerable(Of T)
C# 
public static IEnumerable<T> Merge( 
   IComparer<T> comparer,
   IEnumerable<T> x,
   IEnumerable<T> y
)

Parameters

comparer
x
y

Example

Library/Library.Test/TestOrderedEnumeration.cs

C#Copy Code
char[] x = "aeiou".ToCharArray();
char[] y = "bcdfg".ToCharArray();
char[] z = "ez".ToCharArray();

var order = OrderedEnumeration<char>.Merge(x, y, z);
Assert.AreEqual("abcdeefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, DuplicateHandling.LastValueWins, x, y, z);
Assert.AreEqual("abcdefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, x, y);
order = OrderedEnumeration<char>.WithDuplicateHandling(order, Comparer<char>.Default,
                                                       DuplicateHandling.FirstValueWins);
Assert.AreEqual("abcdefgiou", new string(new List<char>(order).ToArray()));
VB.NETCopy Code
Dim x As Char() = "aeiou".ToCharArray()
Dim y As Char() = "bcdfg".ToCharArray()
Dim z As Char() = "ez".ToCharArray()

Dim order As var = OrderedEnumeration(Of Char).Merge(x, y, z)
Assert.AreEqual("abcdeefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], DuplicateHandling.LastValueWins, x, y, z)
Assert.AreEqual("abcdefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], x, y)
order = OrderedEnumeration(Of Char).WithDuplicateHandling(order, Comparer(Of Char).[Default], DuplicateHandling.FirstValueWins)
Assert.AreEqual("abcdefgiou", New String(New List(Of Char)(order).ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys